#include<string>
#include<vector>
#include<array>
#include<unordered_map>
#include<algorithm>
#include<limits>
#include <stack>
#include<iostream>
#include<sstream>
#include<deque>
#define MOD 1000000007
class Solution {
public:
    void solve(std::vector<std::vector<char>>& board) {
        int n = board.size();
        int m = board[0].size();
        for (int i=0;i<m;i++)
        {
            dfs(board,0,i,n,m);
            dfs(board,n-1,i,n,m);
        }
        for (int i=1;i<n-1;i++)
        {
            dfs(board,i,0,n,m);
            dfs(board,i,m-1,n,m);
        }
        for (int i=0;i<n;i++)
        {
            for (int j=0;j<m;j++)
            {
                if (board[i][j] == 'F')
                {
                    board[i][j] = 'O';
                }
               else  if (board[i][j] == 'O')
                {
                    board[i][j] = 'X';
                }
            }
        }
    }
    void dfs(std::vector<std::vector<char>>& board,const int& i,const int& j,const int& n,const int &m)
    {
        if (i<0||i>=n||j<0||j>=m||board[i][j]!='O')
        {
            return;
        }
        board[i][j]='F';
        dfs(board,i+1,j,n,m);
        dfs(board,i-1,j,n,m);
        dfs(board,i,j+1,n,m);
        dfs(board,i,j-1,n,m);
    }
};